# -*- coding: utf-8 -*-
"""
Created on Thu Jul 20 20:05:56 2017

@author: WANGWEIW23
"""
import numpy as np
import pandas as pd
from PIL import Image
import os
from pandas import Series,DataFrame
from collections import Counter
def datafile(picdirec):
    x=[]
    for i in range(len(path)):
        try:
            im=Image.open(path[i])
        except:
            continue
        im.load()
        pixes=np.asarray(im,dtype='float32')
        x.append(pixes)
    shape_list=[]
    for i in range(len(x)):
        shape_list.append(x[i].shape)
    global dict
    dict_num=dict((i,shape_list.count(i)) for i in set(shape_list))
    dict=sorted(dict_num.items(),key=lambda d:d[1],reverse=True)
    img_size=dict[0][0]
    x_resized=[]
    for i in range(len(path)):
        try:
            im=Image.open(path[i])
            im=im.resize((img_size[1],img_size[0]))
        except:
            continue
        im.load()
        pixes=np.asarray(im,dtype='float32')
        x_resized.append(pixes)
    return x,x_resized  



